package net.orange.architecture.db;

import java.util.Collection;
import java.util.Date;

/**
 * The condition object in the SQL Statement ("where....").
 */
public class Condition {

	/**
	 * The field name.
	 */
	private String FieldName;

	/**
	 * The field value
	 */
	private Object FieldValue;

	/**
	 * The operator ("=","<>",">","<"......)
	 */
	private Operator operator;

	/**
	 * The constructor with the field name and field value (String)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, String o) {
		FieldName = f;
		FieldValue = o;
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and field value (int)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, int o) {
		FieldName = f;
		FieldValue = new Integer(o);
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and field value (long)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, long o) {
		FieldName = f;
		FieldValue = new Long(o);
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and field value (float)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, float o) {
		FieldName = f;
		FieldValue = new Float(o);
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and field value (double)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, double o) {
		FieldName = f;
		FieldValue = new Double(o);
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and field value (Date)
	 * 
	 * @param f
	 *            The field name.
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Date o) {
		FieldName = f;
		FieldValue = o;
		operator = new Operator(Operator.EQUAL);
	}

	/**
	 * The constructor with the field name and operator and field value (Date)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, String o) {
		FieldName = f;
		FieldValue = o;
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (int)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, int o) {
		FieldName = f;
		FieldValue = new Integer(o);
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (long)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, long o) {
		FieldName = f;
		FieldValue = new Long(o);
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (float)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, float o) {
		FieldName = f;
		FieldValue = new Float(o);
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (double)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, double o) {
		FieldName = f;
		FieldValue = new Float(o);
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (Date)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, Date o) {
		FieldName = f;
		FieldValue = o;
		operator = r;
	}

	/**
	 * The constructor with the field name and operator and field value (Collection)
	 * 
	 * @param f
	 *            The field name.
	 * @param r
	 *            The operator ("=",">","<"......)
	 * @param o
	 *            The field value.
	 */
	public Condition(String f, Operator r, Collection o) {
		FieldName = f;
		FieldValue = o;
		operator = r;
	}

	/**
	 * @return Returns the fieldName.
	 */
	public String getFieldName() {
		return FieldName;
	}

	/**
	 * @return Returns the fieldValue.
	 */
	public Object getFieldValue() {
		return FieldValue;
	}

	/**
	 * @return Returns the operator.
	 */
	public Operator getOperator() {
		return operator;
	}

	/**
	 * @param fieldName
	 *            The fieldName to set.
	 */
	public void setFieldName(String fieldName) {
		FieldName = fieldName;
	}

	/**
	 * @param fieldValue
	 *            The fieldValue to set.
	 */
	public void setFieldValue(Object fieldValue) {
		FieldValue = fieldValue;
	}

	/**
	 * @param operator
	 *            The operator to set.
	 */
	public void setOperator(Operator operator) {
		this.operator = operator;
	}
}